<template>
  <div>
    <ul>
      <li v-for="(item, index) in list" :key="index">
        <span>{{ item }}</span>
        <button @click.prevent="del(index)">删除</button>
      </li>
    </ul>

    <button @click.prevent="add">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [1, 5, 3],
    };
  },

  methods: {
    add() {
      this.list.push(parseInt(Math.random() * 100));
    },

    del(index) {
      this.list.splice(index, 1);
    },
  },
};
</script>

<style>
</style>